package com.lvkerry.orderfood.config;

import com.lvkerry.orderfood.provider.WxDevelopIdStore;
import com.lvkerry.orderfood.provider.store.RedisWxDevelopIdStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;

/**
 * @author Kerry
 */

@Configuration
public class WxDevelopConfig {

    /// 启用为内存存在
    /*
    @Bean
    public WxDevelopIdStore wxDevelopIdStore() {
        return new InMemoryWxDevelopIdStore();
    }
    */

    /**
     * 启用为redis
     */
    private final RedisConnectionFactory redisConnectionFactory;

    @Autowired
    public WxDevelopConfig(RedisConnectionFactory redisConnectionFactory) {
        this.redisConnectionFactory = redisConnectionFactory;
    }

    @Bean
    public WxDevelopIdStore wxDevelopIdStore() {
        return new RedisWxDevelopIdStore(redisConnectionFactory);
    }
}
